Skip to content

fix: isolate the daemon test's home and drop the dead peer prompt outcome - #11

Merged
andrebrait merged 3 commits into
mainfrom
test-fixtures-pi
Nov 22, 2026
Merged

andrebrait merged 3 commits into
mainfrom
test-fixtures-pi

Conversation

@andrebrait

@andrebrait andrebrait commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #6.

Summary

  • Daemon test isolation. lib/hosts/daemon-runtime.test.mjs set HOME at runtime, but Bun's os.homedir() keeps the HOME it started with. The daemon therefore applied cluster configuration into the real ~/.agents, and nine tests failed on machines where that directory is a symlink. The test now mocks node:os homedir. The file runs in its own process under bun test --parallel, so the mock needs no restore.
  • Peer prompt outcome removed. The wrapper read the runner's t field from peer_prompt_outcome, so that path never fired. It cannot fire under pi either: pi never prints prompt_result or prompt_error, and refuses a message command only in that command's response. Fanning such a refusal out to the other servers would make the elected notifier report "Run failed" for a prompt pi merely declined (a bare prompt during another server's run, or a compaction), and drop the next completed notice. The owning server does not notify for its own refusal either. The frame, its producer, its consumer and their tests are gone.
  • Command map leak. The daemon kept message-command owners in channel.commands waiting for a prompt_result that pi never sends, so every prompt leaked one entry for the channel's life. Every owner is now forgotten at its response. bash_execution_update routing is unchanged, because pi answers bash only after it finishes.
  • Runner leftovers. hub.ts no longer prefilters or matches the runner's "t":"hello"/"t":"session" lines.

The other test files #6 listed already match pi --mode rpc (no {t: ...} frames or ompweb-omp references remain). v10-upgrade.integration.test.mjs no longer exists.

Verification

npm run release:check at 7d60093: typecheck, lint (0 errors), 4116 tests passing, build and smoke all succeed. At 8f7737b: typecheck, lint and the full test suite (4115 pass, 0 fail). Build and smoke are left to CI.

Review

Review round 1 (full): adversarial

Scope: 09b43b6e1..7d60093c6 (whole change). Tool: adversarial-review.

# Severity Location Finding Verdict
1 Medium lib/hosts/daemon-channels.ts:366 The t to type rename has no effect end to end: pi never emits prompt_result/prompt_error, so the daemon never builds a peer outcome. Fixed in 50621b1, then the feature was removed in 8f7737b (see round 2)
2 Low lib/hosts/daemon-channels.ts:359 Message-command owners stay in channel.commands for a prompt_result that never comes: one leaked entry per prompt. Fixed in 50621b1 (owners are forgotten at their response)
3 Low lib/hosts/hub.ts:1391 The type:"session" branch is dead under pi as well. Rejected: harmless, and the tests still use it as a session-identity source. Left for the planned cleanup
4 Nit lib/hosts/hub.ts:1350 The prefilter still matches "t":"hello"/"t":"session". Fixed in 50621b1
5 Nit lib/hosts/link-protocol.ts:69 Stale {t, outcome} doc. Fixed in 50621b1, then removed in 8f7737b

Mutations: reverting the consumer rename turned the rpc-manager test red; removing the homedir mock with a symlinked .agents failed 9 tests and wrote nothing into the symlink's target.

Not checked: Windows USERPROFILE behaviour.

Review round 1 (full): code review

Scope: 09b43b6e1..7d60093c6 (whole change). Tool: code-review-and-quality.

# Severity Location Finding Verdict
1 Medium lib/hosts/daemon-channels.ts:366 Same as adversarial #1: the peer-outcome path is dead under pi, and its tests feed frames nothing produces. Same verdict as adversarial #1
2 Low lib/notification-events.ts:145 The prompt_result status branch is never reached under pi. Rejected for this PR: the server itself still emits prompt_result (agentInvoked:false). Left for the planned cleanup
3 Nit lib/hosts/link-protocol.ts:69 Stale doc. Fixed (see adversarial #5)

Not checked: CI.

Review round 1 (full): simplification

Scope: 09b43b6e1..7d60093c6 (whole change). Tool: code-simplification.

# Severity Location Finding Verdict
1 Nit lib/hosts/daemon-runtime.test.mjs:13 Name the home path once instead of re-reading process.env.HOME. Fixed in 50621b1

Not using tests/mock-builtin.mjs was confirmed correct: the mock must run at module top level, before the daemon is imported and outside any test.

Review round 2 (light): code review

Scope: 7d60093c6..50621b1b2 (since the last reviewed head). Tool: code-review-and-quality.

# Severity Location Finding Verdict
1 High lib/hosts/daemon-channels.ts:364 Fanning a refused message command out as a peer prompt_error makes the elected notifier report "Run failed" for a refusal (a bare prompt during a run, a compaction, /rename), suppresses the next completed notice, and differs from the owner, which never notifies a refusal. Fixed in 8f7737b (the peer outcome is removed entirely)
2 Nit lib/hosts/daemon-channels.test.mjs:238 The test only covers a refused prompt with both members present. Moot after 8f7737b: the test now asserts that a refusal reaches only its sender

Forgetting message-command owners at their response was confirmed safe for bash, linkGone, channel-lifecycle, extension commands and the write-failure path.

Review round 3 (light): code review

Scope: 50621b1b2..8f7737bd4 (since the last reviewed head). Tool: code-review-and-quality, by the author.

# Severity Location Finding Verdict
- - - No findings. The interdiff only removes code (the frame, its producer and consumer, their tests), and no tau daemon can send the removed frame. -

Round head 8f7737bd47cb46002a86a97bb33724bc105dac39. Rounds used: 3 of 3 after the first full review. No further round is due unless a High finding appears.

Summary by CodeRabbit

  • Behavior Updates
    • Prompt responses are now delivered only to the link that sent the prompt, with the original request ID and outcome preserved.
    • Other members of a shared channel no longer receive notifications about another link’s prompt outcome.
  • Documentation
    • Updated the notifications documentation to reflect that prompt outcomes are not shared with other servers on a channel.

…home

The daemon sends a peer server's prompt outcome as the frame it received, keyed by `type`, but the wrapper still read the runner's `t` field, so another server's failed prompt never notified. The test fed the old shape and hid it.

daemon-runtime.test.mjs set HOME at runtime, which Bun's os.homedir() ignores, so the daemon applied cluster configuration into the real ~/.agents and failed where that is a symlink. The test now mocks homedir.

Also drops hub.ts's dead check for the runner's hello/session frames.

Closes #6
pi never prints prompt_result or prompt_error: it refuses a message command only in that command's response. The daemon now forgets every command at its response and, when pi refuses a message command, tells the other members as a prompt_error peer outcome, so the elected notifier reports the failure. The daemon's routing of child prompt_result/prompt_error frames, which nothing produces, is gone, and with it the message-command entries it kept for them for the channel's life.

Also drops hub.ts's remaining runner `"t"` prefilter and the stale `{t, outcome}` doc.
pi refuses a message command only in that command's response, and the owning server does not notify for its own refusal. Fanning a refusal out as a peer prompt_error made the elected notifier report "Run failed" for a prompt pi merely declined (a bare prompt during another server's run, a compaction) and drop the next completed notice. A refusal now reaches only the server that sent it; the frame, its consumer and their tests are gone.
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes route prompt responses to their sending link and remove peer prompt outcome notifications. Session tracking no longer uses legacy frame markers. The runtime test now mocks home-directory lookups to use a temporary home.

Changes: RPC protocol handling

Layer / File(s) Summary
Route prompt responses to their sender
lib/hosts/link-protocol.ts, lib/hosts/daemon-channels.ts, lib/hosts/daemon-channels.test.mjs, lib/rpc-manager.ts, lib/rpc-manager.test.mjs, AGENTS.md
Response frames are returned to their sending link with the original ID. Peer prompt outcome frames are no longer exported, broadcast, or converted into notifications. Tests check accepted and refused responses reach only the sender. The Notifications documentation no longer describes peer outcome frames.
Track sessions from current frame forms
lib/hosts/hub.ts
Session tracking no longer extracts identity from legacy t: "hello" or t: "session" frames. It retains handling for get_state responses and type: "session" frames.

Runtime test environment

Layer / File(s) Summary
Isolate runtime home-directory lookups
lib/hosts/daemon-runtime.test.mjs
The test sets HOME and USERPROFILE to a temporary home and mocks node:os.homedir() to return it.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • ompweb-dev/tau#10: Both PRs modify lib/hosts/daemon-runtime.test.mjs; this PR mocks homedir() to isolate the test from the real home directory.
Merge Risk: Minimal · up to 8f773

This change routes prompt responses only to the link that sent them, drops legacy session markers, and isolates the runtime test's home directory. No concrete regression was found, so it looks ready to merge once CI passes build and smoke.

Security architecture risk: Minimal · up to 8f773

The inspected changes preserve sender-scoped command responses and existing membership checks while narrowing session-identity inputs. No introduced or worsened security, ownership, or failure-containment risk was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed response-routing behavior operates within an existing shared channel and its member links. The inspected paths do not introduce a new destination or broader recipient set for matching command responses.

Trust Boundaries and Controls

  • observed — Incoming channel commands require membership. Responses resolve their stored owner against current membership; explicit close nulls outstanding ownership for that link, preventing those entries from being delivered to a later member with the same link ID.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title has a conventional fix: prefix and names two real changes in the changeset: isolating the daemon test's home directory (daemon-runtime.test.mjs mocks node:os homedir and sets HOME/USERPROFIL…
Linked Issues check Passed Issue #6 has one direct coding requirement. Update the listed test suites to match pi --mode rpc, and pass npm run release:check.

Evidence:
- lib/hosts/daemon-runtime.test.mjs (head): mocks `no…
Out of Scope Changes check Passed The changes, grouped by purpose:

1. Test fixtures named in #6: daemon-runtime.test.mjs (homedir mock), daemon-channels.test.mjs and rpc-manager.test.mjs (assertions for removed frames).
2. Prod…
Full details: Title check

Explanation

The title has a conventional fix: prefix and names two real changes in the changeset: isolating the daemon test's home directory (daemon-runtime.test.mjs mocks node:os homedir and sets HOME/USERPROFILE to a temp dir) and removing the peer prompt outcome frame (PEER_PROMPT_OUTCOME_FRAME removed from link-protocol.ts, daemon-channels.ts, and rpc-manager.ts). It is concise and specific. The changeset also includes other changes (hub.ts legacy frame prefilter removal, response-based command cleanup, test updates), which the title does not need to cover. Both main changes are present, so the title is related and specific enough.

Full details: Linked Issues check

Explanation

Issue #6 has one direct coding requirement. Update the listed test suites to match pi --mode rpc, and pass npm run release:check.

Evidence:

  • lib/hosts/daemon-runtime.test.mjs (head): mocks node:os homedir with mock.module, so the daemon no longer applies configuration into the real home. This matches the issue's scope for that file.
  • lib/hosts/link-integration.test.mjs (head): its fake pi emits response, agent_start, message_update, and agent_end frames. It does not emit {t: ...} frames or ompweb-omp names. This matches pi RPC mode.
  • lib/hosts/daemon-channels.test.mjs, lib/rpc-manager.test.mjs: the PR removes the prompt_result/prompt_error peer-outcome assertions. It keeps the response assertions.
  • pool-starts.test.mjs, update-worker.test.mjs, rpc-manager.test.mjs: the PR states these already match pi. I did not open them. The full suite at 8f7737b (4115 pass, 0 fail) is consistent with that claim.
  • v10-upgrade.integration.test.mjs: the PR states the file no longer exists. I did not confirm this with a file listing in lib/hosts at head. The lib/hosts listing I read does not include it.

Gap: the issue also requires release:check. The PR reports the full gate at 7d60093 (typecheck, lint, 4116 tests, build, smoke). At 8f7737b it reports typecheck, lint, and tests only. Build and smoke were left to CI.

Full details: Out of Scope Changes check

Explanation

The changes, grouped by purpose:

  1. Test fixtures named in #6: daemon-runtime.test.mjs (homedir mock), daemon-channels.test.mjs and rpc-manager.test.mjs (assertions for removed frames).
  2. Production removal of the peer-outcome frame (PEER_PROMPT_OUTCOME_FRAME in link-protocol.ts, its producer in daemon-channels.ts, its consumer in rpc-manager.ts). The PR says pi never emits prompt_result or prompt_error. This is the same legacy assumption that #6 asks to remove, so it relates to the issue. It is not a demonstrated unrelated change.
  3. Production fix to the command-map leak in daemon-channels.ts. The daemon waited for a prompt_result that pi never sends. This also follows from the legacy assumption. bash_execution_update routing is unchanged.
  4. hub.ts prefilter and noteSession cleanup for t: "hello"/t: "session". These remove legacy runner-protocol handling. This matches the issue's goal of matching pi RPC mode.
  5. Doc updates (AGENTS.md notification docs, link-protocol.ts comment) that match the removed behavior.

No change adds behavior that the issue does not connect to. The hub.ts and daemon removals are broader than test-only edits. The issue theme of pi RPC alignment covers them, and the PR explains each one.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 83b78963-bc48-46a6-aa17-1ef3ef334e33
Commits

Reviewing files that changed from the base of the PR and between 09b43b6 and 8f7737b.

Files selected for processing: 8

  • AGENTS.md
  • lib/hosts/daemon-channels.test.mjs
  • lib/hosts/daemon-channels.ts
  • lib/hosts/daemon-runtime.test.mjs
  • lib/hosts/hub.ts
  • lib/hosts/link-protocol.ts
  • lib/rpc-manager.test.mjs
  • lib/rpc-manager.ts
Files with no reviewable changes: 2

  • lib/hosts/link-protocol.ts
  • lib/rpc-manager.test.mjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@andrebrait
andrebrait merged commit 515bebb into main Nov 22, 2026
5 checks passed
@andrebrait
andrebrait deleted the test-fixtures-pi branch November 22, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update remaining test fixtures for pi --mode rpc and pass full release:check

1 participant